/**
 * First we will load all of this project's JavaScript dependencies which
 * include Vue and Vue Resource. This gives a great starting point for
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./src/bootstrap')
import VueRouter from 'vue-router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
// noinspection Eslint
Vue.use(VueRouter)
// noinspection Eslint
Vue.use(ElementUI)

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the body of the page. From here, you may begin adding components to
 * the application, or feel free to tweak this setup for your needs.
 */

// common functions
import UtilsFunctions from './src/Utils'

// components
import CurrentPositions from './CurrentPositions.vue'
import ExpiredPosting from './ExpiredPosting.vue'
import PositionDetail from './PositionDetail.vue'
import NewPosition from './CreateNewPosition.vue'
import EditPosition from './EditPosition.vue'

const routes = [
  { path: '/', component: CurrentPositions },
  { path: '/curpositions', component: CurrentPositions },
  { path: '/expiredposting', component: ExpiredPosting },
  { path: '/newposition', component: NewPosition },
  { path: '/position/:id', name: 'positionDetail', component: PositionDetail },
  { path: '/update/:id', name: 'updatePosition', component: EditPosition }
]

window.router = new VueRouter({
  routes
})

// noinspection Eslint
Vue.mixin({
  methods: {
    getCurPositions (instance, callback) {
      UtilsFunctions.AjaxGetCurPositions(instance, callback)
    },
    getExpiredPositions (instance, callback) {
      UtilsFunctions.AjaxGetExpiredPositions(instance, callback)
    },
    getPositionsById (instance, callback) {
      UtilsFunctions.AjaxGetPositionsById(instance, callback)
    },
    updatePosition (instance, options, callback) {
      UtilsFunctions.AjaxUpdatePosition(instance, options, callback)
    },
    createPosition (instance, options, callback) {
      UtilsFunctions.AjaxCreatePosition(instance, options, callback)
    },
    deletePosition (instance, callback) {
      UtilsFunctions.AjaxDeletePosition(instance, callback)
    }
  }
})

// noinspection Eslint
const app = new Vue({
  router
}).$mount('#app')
